//
//  CTPDrawLine.m
//  LittleNotes
//
//  Created by 檀志文 on 16/5/21.
//  Copyright © 2016年 ios檀志文. All rights reserved.
//

#import "CTPDrawLine.h"

@implementation CTPDrawLine

- (void)drawRect:(CGRect)rect{
    //   获得图形上下文
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    //   拼接路径
    CGFloat topCircleX = rect.size.width * 0.5;
    CGFloat topCircleY = 0;
    //    CGFloat topCircleRadius = 90;
    //    CGFloat topStartAngle = - M_PI;
    //    CGFloat topEndAngle = 0;
    CGContextMoveToPoint(ctx, topCircleX, topCircleY);
    CGContextAddLineToPoint(ctx, topCircleX,rect.size.height*0.2);
    
    // 设置线条颜色
    [[UIColor blackColor] set];
    // 设置线宽
    CGContextSetLineWidth(ctx, 1);
    // 渲染
    CGContextStrokePath(ctx);
    
    // 绘制灰色大眼睛
    CGFloat bigEyeRadius = 4;
    CGFloat bigEyeX = topCircleX;
    CGFloat bigEyeY = topCircleY+bigEyeRadius+rect.size.height*0.2;
    
    CGContextAddArc(ctx, bigEyeX, bigEyeY, bigEyeRadius, 0, 2 * M_PI, 1);
    // 设置颜色
    [[UIColor colorWithRed:62 / 255.0 green:61/255.0 blue:66/255.0 alpha:1.0] set];
    // 渲染
    CGContextStrokePath(ctx);
    
    CGFloat secondLineX = topCircleX;
    CGFloat secondLineY = rect.size.height;
    CGContextMoveToPoint(ctx, topCircleX, bigEyeY+bigEyeRadius);
    
    CGContextAddLineToPoint(ctx, secondLineX, secondLineY);
    // 设置颜色
    [[UIColor colorWithRed:62 / 255.0 green:61/255.0 blue:66/255.0 alpha:1.0] set];
    // 渲染
    CGContextStrokePath(ctx);
}

@end
